﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.Utils;
using Stimulsoft.Report;
using Stimulsoft.Report.Dictionary;
using DevExpress.XtraPrinting;

namespace Gemciler_Uretim.CekListesi
{
    public partial class CekiIrsaliyeKes: DevExpress.XtraEditors.XtraForm
    {
        public CekiIrsaliyeKes()
        {
            InitializeComponent();
        }
        SqlConnecitonClass sqlbaglanti = new SqlConnecitonClass();

        public string sip_bolum_no, sqlconnectstr, ekran_acma_sekli, musteri_kodu, cek_evrakno_seri = "",musteri_adi;
         int satir_no,secilen_satirno;
         public Int32 siparis_RECno, cek_evrakno_sira,secilen_recno;
         string barkod;
            public int aktif_kullanici;
            string AppPath = System.Windows.Forms.Application.StartupPath;
            public string d_plaka, d_sofor, d_musteri, d_telefon, d_seri, secilen_net_miktar;
        private void CekiListesics_Load(object sender, EventArgs e)
        {

            if (ekran_acma_sekli == "yeni")
            {
                CekiListesiYeniEkle fr = new CekiListesiYeniEkle();
                fr.musteri_adi = musteri_adi;
                fr.musteri_kodu = musteri_kodu;
                fr.ShowDialog();
             
                if (fr.isleme_devam == 1)
                {
                    Close();
                }
                
                musteri_kodu = fr.musteri_kodu;
                text_plaka.Text = fr.sofor_plaka;
                text_sofor.Text = fr.sofor_adi;
                text_telefon.Text = fr.sofor_tel;
                text_musteri.Text = fr.musteri_adi;
                text_firma.Text = fr.firma_adi;
                text_musteri_kodu.Text = fr.musteri_kodu;
                cek_evrakno_sira = Convert.ToInt32(sqlbaglanti.CommScalar("SELECT isnull(max(cek_evrakno_sira),0)+1 FROM TK_CEKI_LISTESI where  cek_evrakno_seri='" + cek_evrakno_seri + "'", CommandType.Text));
                 int acik_ceki = Convert.ToInt32(sqlbaglanti.CommScalar("SELECT isnull(max(cek_evrakno_sira),0) FROM TK_CEKI_LISTESI where  cek_kapat=1 and cek_musteri_kodu= '" + musteri_kodu + "'  AND cek_evrakno_seri='" + cek_evrakno_seri + "'", CommandType.Text));
                 if (acik_ceki > 0)
                 {
                    
                         cek_evrakno_sira=acik_ceki;
                         text_plaka.Text = Convert.ToString(sqlbaglanti.CommScalar("SELECT top 1 cek_sip_nakliyeci_plaka FROM TK_CEKI_LISTESI where  cek_evrakno_seri='"+cek_evrakno_seri+"' and  cek_evrakno_sira='"+cek_evrakno_sira+"' and cek_musteri_kodu= '" + musteri_kodu + "'  AND cek_evrakno_seri='" + cek_evrakno_seri + "'", CommandType.Text));
                         text_sofor.Text = Convert.ToString(sqlbaglanti.CommScalar("SELECT top 1 cek_sip_nakliyeci FROM TK_CEKI_LISTESI where  cek_evrakno_seri='"+cek_evrakno_seri+"' and  cek_evrakno_sira='"+cek_evrakno_sira+"' and cek_musteri_kodu= '" + musteri_kodu + "'  AND cek_evrakno_seri='" + cek_evrakno_seri + "'", CommandType.Text));
                         text_telefon.Text = Convert.ToString(sqlbaglanti.CommScalar("SELECT top 1 cek_sip_nakliyeci_tel FROM TK_CEKI_LISTESI where  cek_evrakno_seri='"+cek_evrakno_seri+"' and  cek_evrakno_sira='"+cek_evrakno_sira+"' and cek_musteri_kodu= '" + musteri_kodu + "'  AND cek_evrakno_seri='" + cek_evrakno_seri + "'", CommandType.Text));
                         MessageBox.Show("AÇIK ÇEKİ LİSTESİ VAR ");
                 }
            
            }

            dateEdit1.EditValue = DateTime.Today;

           
           if (ekran_acma_sekli == "değiştir")
           {


               text_plaka.Text = d_plaka;
               text_sofor.Text = d_sofor;
               text_telefon.Text = d_telefon;
               text_musteri.Text = d_musteri;
               text_firma.Text = d_musteri;
               text_musteri_kodu.Text = musteri_kodu;

           }
           if (ekran_acma_sekli == "incele")
           {


               text_plaka.Text = d_plaka;
               text_sofor.Text = d_sofor;
               text_telefon.Text = d_telefon;
               text_musteri.Text = d_musteri;
               text_firma.Text = d_musteri;
               text_musteri_kodu.Text = musteri_kodu;

               _1_satırSilToolStripMenuItem.Enabled = false;

           }

            
            
            text_cekino.Text =cek_evrakno_seri+ ""+ cek_evrakno_sira+"";

            _1_dgv_guncelle();
            text_irs_sira.Text = Convert.ToString(sqlbaglanti.CommScalar("Select isnull(MAX(sth_evrakno_sira),0)+1 FROM STOK_HAREKETLERI WITH (NOLOCK, INDEX=NDX_STOK_HAREKETLERI_05) WHERE sth_tip=1 and  sth_cins=0 and   sth_evrakno_seri=N'" + text_irs_seri.Text + "' and sth_evraktip=1", CommandType.Text));
        
            //combo_firma.DataSource = sqlbaglanti.ShowTable("select nak_kodu AS KOD,nak_unvani AS ADI FROM TK_NAKLIYE_FIRMA_TANIMLARI ORDER BY nak_unvani ", CommandType.Text);
            //combo_firma.DisplayMember = "ADI";
            //combo_firma.ValueMember = "KOD";
            
            
            //combo_nakiyeci.DataSource = sqlbaglanti.ShowTable("select sof_kodu AS KOD,sof_adi AS ADI FROM TK_CEK_SOFOR_TANIMLARI  ORDER BY sof_adi ", CommandType.Text);
            //combo_nakiyeci.DisplayMember = "ADI";
            //combo_nakiyeci.ValueMember = "KOD";

            //siparisOku();
            text_hazirlayan.Text=Convert.ToString(sqlbaglanti.CommScalar("SELECT ku_adi FROM TK_KULLANICI_TANIMLARI WHERE ku_kodu=0",CommandType.Text));
          
        }
        private void _1_dgv_guncelle()
        {

            sqlbaglanti.CommScalar("IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TK_IRS_TEMP]') AND type in (N'U')) DROP TABLE [dbo].[TK_IRS_TEMP]", CommandType.Text);
            sqlbaglanti.CommScalar("CREATE TABLE [dbo].[TK_IRS_TEMP]("
                                +"[RECNO] [int] IDENTITY(1,1) NOT NULL,	[SİPRECNO] [int] NULL,	[SERİ] [varchar](50) NULL,"
                                +"[SIRA] [int] NULL,	[MUS_SİP_NO] [varchar](50) NULL,	[MÜŞTERİ KODU] [varchar](50) NULL,	[NAKİYECİ] [varchar](150) NULL,"
                                +"[NAK_TEL] [varchar](50) NULL,	[NAK_PLAKA] [varchar](50) NULL,	[STOK KODU] [varchar](50) NULL,	[MÜŞTERİ STOK KODU] [varchar](50) NULL,"
                                +"[EN] [varchar](50) NULL,	[BOY] [varchar](50) NULL,	[KALINLIK] [varchar](50) NULL,	[BRÜT] [float] NULL,"
                                +"[PALET] [float] NULL,[KAPAK] [float] NULL,[ADET] [float] NULL,[NET] [float] NULL,"
                                +"[ÖLÇÜ] [varchar](150) NULL,[ADRES] [varchar](150) NULL,	[STOK ADI] [varchar](150) NULL"
                                +") ON [PRIMARY]",CommandType.Text);

            sqlbaglanti.CommScalar("INSERT INTO [TK_IRS_TEMP] (SİPRECNO,[SERİ]  ,[SIRA],[MUS_SİP_NO] ,[MÜŞTERİ KODU],[NAKİYECİ] ,[NAK_TEL]"
                                    + ",[NAK_PLAKA] ,[STOK KODU],[MÜŞTERİ STOK KODU],[EN] ,[BOY]"
                                    + ",[KALINLIK],[BRÜT],[PALET],[KAPAK],[ADET] ,[NET],[ÖLÇÜ] ,[ADRES],[STOK ADI])"
                                    + " SELECT SİPRECNO,SERİ,SIRA,MUS_SİP_NO,[MÜSTERİ KODU],NAKİYECİ,NAK_TEL,NAK_PLAKA,[STOK KODU],[MÜŞTERİ STOK KODU]"
                                    + ",EN,BOY,KALINLIK"
                                    + ",SUM([BRÜT]) AS BRÜT"
                                    + ",SUM([PALET]) AS PALET"
                                    + ",SUM([KAPAK]) AS KAPAK"
                                    + ",SUM([ADET]) AS ADET"
                                    + ",SUM([NET]) AS NET"
                                    + ",MIN(ÖLÇÜ) AS [ÖLÇÜ]"
                                    + ",min(ADRES) AS [ADRES]"
                                    + ",min([STOK ADI]) AS [STOK ADI]"
                                    + " FROM tkfn_CekiListesiGosterMusteri(2,'" + musteri_kodu + "','" + cek_evrakno_seri + "'," + cek_evrakno_sira + ")"
                                    + " GROUP BY SERİ,SIRA,MUS_SİP_NO,[MÜSTERİ KODU],NAKİYECİ,NAK_TEL,NAK_PLAKA,[STOK KODU],[MÜŞTERİ STOK KODU],EN,BOY,KALINLIK,SİPRECNO", CommandType.Text);

            
            
            
            gridControl1.DataSource = null;
            gridView1.Columns.Clear();
            // ---sip_special1='O' VEYA '' ONAY BEKLİYOR 
            gridControl1.DataSource = sqlbaglanti.ShowTable("SELECT * FROM TK_IRS_TEMP", CommandType.Text);
            this.gridControl1.TabIndex = 0;
            this.gridView1.OptionsBehavior.AllowIncrementalSearch = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowGroupPanel = false; // gruplama alanı
            this.gridView1.OptionsBehavior.Editable = false;
            this.gridView1.OptionsBehavior.ReadOnly = false;
            this.gridView1.OptionsView.ShowFooter = true;
            gridView1.OptionsView.ColumnAutoWidth = false;
            this.gridView1.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            this.gridView1.ColumnPanelRowHeight = 55;

            gridView1.OptionsView.HeaderFilterButtonShowMode = FilterButtonShowMode.Button;
            this.gridView1.Columns["YIL"].Visible = false;
            //this.gridView1.Columns["NAKİYECİ"].Visible = false;
            //this.gridView1.Columns["NAK_TEL"].Visible = false;
            //this.gridView1.Columns["NAK_PLAKA"].Visible = false;
            //this.gridView1.Columns["NAKİYECİ"].Visible = false;
            //this.gridView1.Columns["SERİ"].Visible = false;
            //this.gridView1.Columns["SIRA"].Visible = false;
            //this.gridView1.Columns["ADRES"].Visible = false;

            this.gridView1.Columns["KAYITNO"].Visible = false;
            this.gridView1.Columns["SİPRECNO"].Visible = false;
            this.gridView1.Columns["BRÜT"].DisplayFormat.FormatType = FormatType.Numeric;
            this.gridView1.Columns["BRÜT"].DisplayFormat.FormatString = "n2";
            this.gridView1.Columns["BRÜT"].Width = 80;
            gridView1.Columns["PALET"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            gridView1.Columns["PALET"].SummaryItem.DisplayFormat = "{0:N2}";
            gridView1.Columns["PALET"].SummaryItem.Tag = 1;
            gridView1.Columns["KAPAK"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            gridView1.Columns["KAPAK"].SummaryItem.DisplayFormat = "{0:N0}";
            gridView1.Columns["KAPAK"].SummaryItem.Tag = 1;

            gridView1.Columns["ADET"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            gridView1.Columns["ADET"].SummaryItem.DisplayFormat = "{0:N0}";
            gridView1.Columns["ADET"].SummaryItem.Tag = 1;

            gridView1.Columns["NET"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            gridView1.Columns["NET"].SummaryItem.DisplayFormat = "{0:N0}";
            gridView1.Columns["NET"].SummaryItem.Tag = 1;

            gridView1.Columns["ÖLÇÜ"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Count;
            gridView1.Columns["ÖLÇÜ"].SummaryItem.DisplayFormat = "{0:N0} ADET";
            gridView1.Columns["ÖLÇÜ"].SummaryItem.Tag = 1;

       


            gridView1.BestFitColumns();

            degiskenSifirla();
        }
        private void kayitIslemineBasla()
        {
            
            
            for (int i = 0; i < gridView1.RowCount; i++)
            {


               secilen_recno = Convert.ToInt32(gridView1.GetRowCellValue(i, "RECNO").ToString());
               siparis_RECno = Convert.ToInt32(gridView1.GetRowCellValue(i, "SİPRECNO").ToString());
               secilen_net_miktar = Convert.ToString(gridView1.GetRowCellValue(i, "NET").ToString());

               sth_kayit();
            }
        }

        private void sth_kayit()
        {



            //sth_tutar = sth_miktar * Convert.ToDouble(sqlbaglanti.CommScalar("select dbo.tk_brut_sonalis('" + sth_stok_kod + "')", CommandType.Text));

            string stok_kodu="";
            string tksth_tutar = Convert.ToString(0);
            tksth_tutar = tksth_tutar.Replace(",", ".");
            string tksth_vergi_tutari="", tksth_miktar = Convert.ToString(0);
            tksth_miktar = tksth_miktar.Replace(",", ".");
            secilen_net_miktar = secilen_net_miktar.Replace(",",".");
            //sth_vergi_pntr = Convert.ToInt16(sqlbaglanti.CommScalar("SELECT isnull(sto_toptan_vergi,0) FROM STOKLAR WHERE  sto_kod='" + sth_stok_kod + "'  ", CommandType.Text));
            //double vergi_orani = Convert.ToDouble(sqlbaglanti.CommScalar("select dbo.fn_VergiYuzde(" + sth_vergi_pntr + ")", CommandType.Text));
            //sth_vergi = ((sth_tutar * vergi_orani) / 100);
            //string tksth_vergi_tutari = Convert.ToString(sth_vergi);
            //tksth_vergi_tutari = tksth_vergi_tutari.Replace(",", ".");

           int sth_satirno = Convert.ToInt16(sqlbaglanti.CommScalar("SELECT isnull(max(sth_satirno),-1) FROM STOK_HAREKETLERI WHERE  sth_evrakno_seri='" + text_irs_seri.Text + "' and  sth_evrakno_sira= " + text_irs_sira.Text + "  ", CommandType.Text));
            sth_satirno = sth_satirno + 1;
            string sip_kayit_kalan = Convert.ToString(0);
            sip_kayit_kalan = sip_kayit_kalan.Replace(",", ".");

            sqlbaglanti.CommScalar("INSERT INTO STOK_HAREKETLERI  ("
+ " sth_RECid_DBCno,"
+ " sth_RECid_RECno,"
+ " sth_SpecRECno,"
+ " sth_iptal,"
+ " sth_fileid,"
+ " sth_hidden,"
+ " sth_kilitli,"
+ " sth_degisti,"
+ " sth_checksum,"
+ " sth_create_user,"
+ " sth_create_date,"
+ " sth_lastup_user,"
+ " sth_lastup_date,"
+ " sth_special1,"
+ " sth_special2,"
+ " sth_special3,"
+ " sth_firmano,"
+ " sth_subeno,"
+ " sth_tarih,"
+ " sth_tip,"
+ " sth_cins,"
+ " sth_normal_iade,"
+ " sth_evraktip,"
+ " sth_evrakno_seri,"
+ " sth_evrakno_sira,"
+ " sth_satirno,"
+ " sth_belge_no,"
+ " sth_belge_tarih,"
+ " sth_stok_kod,"
+ " sth_isk_mas1,"
+ " sth_isk_mas2,"
+ " sth_isk_mas3,"
+ " sth_isk_mas4,"
+ " sth_isk_mas5,"
+ " sth_isk_mas6,"
+ " sth_isk_mas7,"
+ " sth_isk_mas8,"
+ " sth_isk_mas9,"
+ " sth_isk_mas10,"
+ " sth_sat_iskmas1,"
+ " sth_sat_iskmas2,"
+ " sth_sat_iskmas3,"
+ " sth_sat_iskmas4,"
+ " sth_sat_iskmas5,"
+ " sth_sat_iskmas6,"
+ " sth_sat_iskmas7,"
+ " sth_sat_iskmas8,"
+ " sth_sat_iskmas9,"
+ " sth_sat_iskmas10,"
+ " sth_pos_satis,"
+ " sth_promosyon_fl,"
+ " sth_cari_cinsi,"
+ " sth_cari_kodu,"
+ " sth_cari_grup_no,"
+ " sth_isemri_gider_kodu,"
+ " sth_ismerkezi_kodu,"
+ " sth_plasiyer_kodu,"
+ " sth_kur_tarihi,"
+ " sth_har_doviz_cinsi,"
+ " sth_har_doviz_kuru,"
+ " sth_alt_doviz_kuru,"
+ " sth_stok_doviz_cinsi,"
+ " sth_stok_doviz_kuru,"
+ " sth_miktar,"
+ " sth_miktar2,"
+ " sth_birim_pntr,"
+ " sth_tutar,"
+ " sth_iskonto1,"
+ " sth_iskonto2,"
+ " sth_iskonto3,"
+ " sth_iskonto4,"
+ " sth_iskonto5,"
+ " sth_iskonto6,"
+ " sth_masraf1,"
+ " sth_masraf2,"
+ " sth_masraf3,"
+ " sth_masraf4,"
+ " sth_vergi_pntr,"
+ " sth_vergi,"
+ " sth_masraf_vergi_pntr,"
+ " sth_masraf_vergi,"
+ " sth_netagirlik,"
+ " sth_odeme_op,"
+ " sth_aciklama,"
+ " sth_sip_recid_dbcno,"
+ " sth_sip_recid_recno,"
+ " sth_fat_recid_dbcno,"
+ " sth_fat_recid_recno,"
+ " sth_giris_depo_no,"
+ " sth_cikis_depo_no,"
+ " sth_malkbl_sevk_tarihi,"
+ " sth_cari_srm_merkezi,"
+ " sth_stok_srm_merkezi,"
+ " sth_fis_tarihi,"
+ " sth_fis_sirano,"
+ " sth_vergisiz_fl,"
+ " sth_maliyet_ana,"
+ " sth_maliyet_alternatif,"
+ " sth_maliyet_orjinal,"
+ " sth_adres_no,"
+ " sth_parti_kodu,"
+ " sth_lot_no,"
+ " sth_kons_recid_dbcno,"
+ " sth_kons_recid_recno,"
+ " sth_subesip_recid_dbcno,"
+ " sth_subesip_recid_recno,"
+ " sth_vardiya_tarihi,"
+ " sth_vardiya_no,"
+ " sth_satistipi,"
+ " sth_proje_kodu,"
+ " sth_ihracat_kredi_kodu,"
+ " sth_exim_kodu,"
+ " sth_otv_pntr,"
+ " sth_otv_vergi,"
+ " sth_bkm_recid_dbcno,"
+ " sth_bkm_recid_recno,"
+ " sth_karsikons_recid_dbcno,"
+ " sth_karsikons_recid_recno,"
+ " sth_iade_evrak_seri,"
+ " sth_iade_evrak_sira,"
+ " sth_diib_belge_no,"
+ " sth_diib_satir_no,"
+ " sth_mensey_ulke_tipi,"
+ " sth_mensey_ulke_kodu,"
+ " sth_brutagirlik,"
+ " sth_halrehmiktari,"
+ " sth_halrehfiyati,"
+ " sth_halsandikmiktari,"
+ " sth_halsandikfiyati,"
+ " sth_halsandikkdvtutari,"
+ " sth_disticaret_turu,"
+ " sth_otvtutari,"
+ " sth_otvvergisiz_fl,"
+ " sth_direkt_iscilik_1,"
+ " sth_direkt_iscilik_2,"
+ " sth_direkt_iscilik_3,"
+ " sth_direkt_iscilik_4,"
+ " sth_direkt_iscilik_5,"
+ " sth_genel_uretim_1,"
+ " sth_genel_uretim_2,"
+ " sth_genel_uretim_3,"
+ " sth_genel_uretim_4,"
+ " sth_genel_uretim_5,"
+ " sth_yat_tes_kodu,"
+ " sth_oiv_pntr,"
+ " sth_oiv_vergi,"
+ " sth_oivvergisiz_fl,"
+ " sth_fiyat_liste_no,"
+ " sth_fis_tarihi2,"
+ " sth_fis_sirano2,"
+ " sth_rez_recid_dbcno,"
+ " sth_rez_recid_recno,"
+ " sth_fiyfark_esas_evrak_seri,"
+ " sth_fiyfark_esas_evrak_sira,"
+ " sth_fiyfark_esas_satir_no,"
+ " sth_optamam_recid_dbcno,"
+ " sth_optamam_recid_recno,"
+ " sth_oivtutari,"
+ " sth_Tevkifat_turu,"
+ " sth_HalKomisyonuKdv,"
+ " sth_iadeTlp_recid_dbcno,"
+ " sth_iadeTlp_recid_recno,"
+ " sth_HalSatisRecid_dbcno,"
+ " sth_HalSatisRecid_recno,"
+ " sth_nakliyedeposu,"
+ " sth_nakliyedurumu,"
+ " sth_ciroprim_dbcno,"
+ " sth_ciroprim_recno,"
+ " sth_yetkili_recid_dbcno,"
+ " sth_yetkili_recid_recno,"
+ " sth_taxfree_fl)"
                ////
+ "SELECT "
+ " 0,"             /// sth_RECid_DBCno
+ " 0,"             /// sth_RECid_RECno
+ " 0,"             /// sth_SpecRECno
+ " 0,"             /// sth_iptal
+ " 16,"             /// sth_fileid
+ " 0,"             /// sth_hidden
+ " 0,"             /// sth_kilitli
+ " 0,"             /// sth_degisti
+ " 0,"             /// sth_checksum
+ " " + aktif_kullanici + " ,"             /// sth_create_user
+ " GETDATE() ,"             /// sth_create_date
+ " " + aktif_kullanici + ","             /// sth_lastup_user
+ " GETDATE(),"             /// sth_lastup_date
+ " '',"             /// sth_special1
+ " '',"             /// sth_special2
+ " '',"             /// sth_special3
+ " 0,"             /// sth_firmano
+ " 0,"             /// sth_subeno
+ " CONVERT(NVARCHAR(10),GETDATE(),112),"             /// sth_tarih
+ " 1,"             /// sth_tip
+ " 0,"             /// sth_cins
+ " 0,"             /// sth_normal_iade
+ " 1,"             /// sth_evraktip
+ " '" + text_irs_seri.Text+ "',"             /// sth_evrakno_seri
+ " " + text_irs_sira.Text+ ","             /// sth_evrakno_sira
+ " " + sth_satirno + ","             /// sth_satirno
+ " N'',"             /// sth_belge_no
+ " '',"             /// sth_belge_tarih
+ " [STOK KODU],"             /// sth_stok_kod
+ " 1,"             /// sth_isk_mas1
+ " 1,"             /// sth_isk_mas2
+ " 1,"             /// sth_isk_mas3
+ " 1,"             /// sth_isk_mas4
+ " 1,"             /// sth_isk_mas5
+ " 1,"             /// sth_isk_mas6
+ " 1,"             /// sth_isk_mas7
+ " 1,"             /// sth_isk_mas8
+ " 1,"             /// sth_isk_mas9
+ " 1,"             /// sth_isk_mas10
+ " 0,"             /// sth_sat_iskmas1
+ " 0,"             /// sth_sat_iskmas2
+ " 0,"             /// sth_sat_iskmas3
+ " 0,"             /// sth_sat_iskmas4
+ " 0,"             /// sth_sat_iskmas5
+ " 0,"             /// sth_sat_iskmas6
+ " 0,"             /// sth_sat_iskmas7
+ " 0,"             /// sth_sat_iskmas8
+ " 0,"             /// sth_sat_iskmas9
+ " 0,"             /// sth_sat_iskmas10
+ " 0,"             /// sth_pos_satis
+ " 0,"             /// sth_promosyon_fl
+ " 0,"             /// sth_cari_cinsi
+ " [MÜŞTERİ KODU],"             /// sth_cari_kodu
+ " 0,"             /// sth_cari_grup_no
+ " N'',"             /// sth_isemri_gider_kodu
+ " '',"             /// sth_ismerkezi_kodu
+ " '',"             /// sth_plasiyer_kodu
+ " '18991230',"             /// sth_kur_tarihi
+ " 0,"             /// sth_har_doviz_cinsi
+ " 1,"             /// sth_har_doviz_kuru
+ " 1,"             /// sth_alt_doviz_kuru
+ " 0,"             /// sth_stok_doviz_cinsi
+ " 1,"             /// sth_stok_doviz_kuru
+ " [NET],"             /// sth_miktar
+ " [BRÜT]  ,"             /// sth_miktar2
+ " 1,"             /// sth_birim_pntr
+ " 0,"             /// sth_tutar
+ " 0,"             /// sth_iskonto1
+ " 0,"             /// sth_iskonto2
+ " 0,"             /// sth_iskonto3
+ " 0,"             /// sth_iskonto4
+ " 0,"             /// sth_iskonto5
+ " 0,"             /// sth_iskonto6
+ " 0,"             /// sth_masraf1
+ " 0,"             /// sth_masraf2
+ " 0,"             /// sth_masraf3
+ " 0,"             /// sth_masraf4
+ " 4,"             /// sth_vergi_pntr
+ " 0,"             /// sth_vergi
+ " 0,"             /// sth_masraf_vergi_pntr
+ " 0,"             /// sth_masraf_vergi
+ " 0,"             /// sth_netagirlik
+ " 0,"             /// sth_odeme_op
+ "[ÖLÇÜ],"             /// sth_aciklama
+ " 0,"             /// sth_sip_recid_dbcno
+ " SİPRECNO,"             /// sth_sip_recid_recno
+ " 0,"             /// sth_fat_recid_dbcno
+ " 0,"             /// sth_fat_recid_recno
+ "1,"             /// sth_giris_depo_no
+ " 1,"             /// sth_cikis_depo_no
+ " CONVERT(NVARCHAR(10),GETDATE(),112),"             /// sth_malkbl_sevk_tarihi
+ "'' ,"             /// sth_cari_srm_merkezi
+ " '',"             /// sth_stok_srm_merkezi
+ " '18991230',"             /// sth_fis_tarihi
+ " 0,"             /// sth_fis_sirano
+ " 0,"             /// sth_vergisiz_fl
+ " 0,"             /// sth_maliyet_ana
+ " 0,"             /// sth_maliyet_alternatif
+ " 0,"             /// sth_maliyet_orjinal
+ " 1,"             /// sth_adres_no
+ " N'',"             /// sth_parti_kodu
+ " 0,"             /// sth_lot_no
+ " 0,"             /// sth_kons_recid_dbcno
+ " 0,"             /// sth_kons_recid_recno
+ " 0,"             /// sth_subesip_recid_dbcno
+ " 0,"             /// sth_subesip_recid_recno
+ " '18991230',"             /// sth_vardiya_tarihi
+ " 0,"             /// sth_vardiya_no
+ " 0,"             /// sth_satistipi
+ " '',"             /// sth_proje_kodu
+ " N'',"             /// sth_ihracat_kredi_kodu
+ " N'',"             /// sth_exim_kodu
+ " 0,"             /// sth_otv_pntr
+ " 0,"             /// sth_otv_vergi
+ " 0,"             /// sth_bkm_recid_dbcno
+ " 0,"             /// sth_bkm_recid_recno
+ " 0,"             /// sth_karsikons_recid_dbcno
+ " 0,"             /// sth_karsikons_recid_recno
+ " N'',"             /// sth_iade_evrak_seri
+ " 0,"             /// sth_iade_evrak_sira
+ " N'',"             /// sth_diib_belge_no
+ " 0,"             /// sth_diib_satir_no
+ " 0,"             /// sth_mensey_ulke_tipi
+ " N'',"             /// sth_mensey_ulke_kodu
+ " 0,"             /// sth_brutagirlik
+ " 0,"             /// sth_halrehmiktari
+ " 0,"             /// sth_halrehfiyati
+ " 0,"             /// sth_halsandikmiktari
+ " 0,"             /// sth_halsandikfiyati
+ " 0,"             /// sth_halsandikkdvtutari
+ " 0,"             /// sth_disticaret_turu
+ " 0,"             /// sth_otvtutari
+ " 0,"             /// sth_otvvergisiz_fl
+ " 0,"             /// sth_direkt_iscilik_1
+ " 0,"             /// sth_direkt_iscilik_2
+ " 0,"             /// sth_direkt_iscilik_3
+ " 0,"             /// sth_direkt_iscilik_4
+ " 0,"             /// sth_direkt_iscilik_5
+ " 0,"             /// sth_genel_uretim_1
+ " 0,"             /// sth_genel_uretim_2
+ " 0,"             /// sth_genel_uretim_3
+ " 0,"             /// sth_genel_uretim_4
+ " 0,"             /// sth_genel_uretim_5
+ " N'',"             /// sth_yat_tes_kodu
+ " 0,"             /// sth_oiv_pntr
+ " 0,"             /// sth_oiv_vergi
+ " 0,"             /// sth_oivvergisiz_fl
+ " 0,"             /// sth_fiyat_liste_no
+ " '18991230',"             /// sth_fis_tarihi2
+ " 0,"             /// sth_fis_sirano2
+ " 0,"             /// sth_rez_recid_dbcno
+ " 0,"             /// sth_rez_recid_recno
+ " N'',"             /// sth_fiyfark_esas_evrak_seri
+ " 0,"             /// sth_fiyfark_esas_evrak_sira
+ " 0,"             /// sth_fiyfark_esas_satir_no
+ " 0,"             /// sth_optamam_recid_dbcno
+ " 0,"             /// sth_optamam_recid_recno
+ " 0,"             /// sth_oivtutari
+ " 0,"             /// sth_Tevkifat_turu
+ " 0,"             /// sth_HalKomisyonuKdv
+ " 0,"             /// sth_iadeTlp_recid_dbcno
+ " 0,"             /// sth_iadeTlp_recid_recno
+ " 0,"             /// sth_HalSatisRecid_dbcno
+ " 0,"             /// sth_HalSatisRecid_recno
+ " 0,"             /// sth_nakliyedeposu
+ " 0,"             /// sth_nakliyedurumu
+ " 0,"             /// sth_ciroprim_dbcno
+ " 0,"             /// sth_ciroprim_recno
+ " 0,"             /// sth_yetkili_recid_dbcno
+ " 0,"             /// sth_yetkili_recid_recno
+ " 0 FROM TK_IRS_TEMP WHERE RECNO="+secilen_recno+""             /// sth_taxfree_fl

+ " ", CommandType.Text);


            //  sqlbaglanti.CommScalar(" UPDATE SIPARISLER SET sip_teslim_miktar=sip_teslim_miktar+"+tksth_miktar+" where    sip_RECno=" + sip_RECno + "", CommandType.Text);

            sqlbaglanti.CommScalar("UPDATE STOK_HAREKETLERI SET  sth_RECid_RECno=sth_RECno where sth_RECid_RECno=0", CommandType.Text);

            sqlbaglanti.CommScalar(" UPDATE SIPARISLER SET sip_teslim_miktar=sip_teslim_miktar+" + secilen_net_miktar + " where    sip_RECno=" + secilen_recno + "", CommandType.Text);
                      


           
        }
        private void siparisOku()
        {
           
       

        }
        private void ceki_liste_kaydet()
        {

            string brut,net,adet,palet,kapak;
            brut=calc_brut.Value.ToString();
            brut=brut.Replace(",",".");
            net=calc_net.Value.ToString();
            net=net.Replace(",",".");
            adet=calc_adet.Value.ToString();
            adet=adet.Replace(",",".");
            palet=calc_palet.Value.ToString();
            palet=palet.Replace(",",".");
            kapak=calc_kapak.Value.ToString();
            kapak=kapak.Replace(",",".");

            //sqlbaglanti.CommScalar("INSERT INTO [TK_CEKI_LISTESI] "
            //    + "            ([cek_create_date]"
            //    + "            ,[cek_create_user]"
            //    + "            ,[cek_satirno]"
            //    + "            ,[cek_sip_recno]"
            //    + "            ,[cek_musteri_sip_no]"
            //    + "            ,[cek_olcu]"
            //    + "            ,[cek_brut]"
            //    + "            ,[cek_palet]"
            //    + "            ,[cek_kapak]"
            //    + "            ,[cek_net]"
            //    + "            ,[cek_adet]"
            //    + "            ,[cek_kapat]"
            //    + "            ,[cek_bolum_no],cek_musteri_kodu,cek_barkodu)"


            //    + " VALUES( "
            //    + " GETDATE() "             ///            ([cek_create_date]
            //    + " ," + aktif_kullanici + ""             ///            ,[cek_create_user]
            //    + "," + satir_no + ""             ///            ,[cek_satirno]
            //    + " ," + siparis_RECno + ""             ///            ,[cek_sip_recno]

            //    + " ,'" + text_mus_sip.Text + "'"             ///            ,[cek_musteri_sip_no]
            //    + " ,'" + text_olcu.Text + "'"             ///            ,[cek_olcu]
            //    + " ," + brut + ""             ///            ,[cek_brut]
            //    + " ," + palet + ""             ///            ,[cek_palet]
            //    + " ," + kapak + ""             ///            ,[cek_kapak]
            //    + " ," + net + ""             ///            ,[cek_net]
            //    + " ," + adet + ""             ///            ,[cek_adet]
            //    + " ,0,'" + sip_bolum_no + "','" + musteri_kodu + "',9999"            ///            ,[cek_kapat],muster kodu
            //    + " )", CommandType.Text);
            
            sqlbaglanti.CommScalar("UPDATE TK_CEKI_LISTESI SET cek_barkodu=  cast((cast([cek_RECno]  AS VARCHAR (15))+''+cast(year([cek_create_date]) AS VARCHAR (4))) AS INT)     WHERE cek_barkodu=9999",CommandType.Text);

            if (MessageBox.Show("BARKOD YAZILSINMI  ", "Onay Ekranı", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                secilen_satirno =Convert.ToInt16( text_sn.Text);
                FormuYAZDIR();
            }
                

        }
        private void degiskenSifirla()
        {
            satir_no = Convert.ToInt32(sqlbaglanti.CommScalar("SELECT isnull( max(cek_satirno),0)+1 from TK_CEKI_LISTESI WHERE  cek_evrakno_seri='" + cek_evrakno_seri + "' and cek_evrakno_sira ="+cek_evrakno_sira+"  AND cek_musteri_kodu='" + musteri_kodu + "'", CommandType.Text));
            text_sn.Text = Convert.ToString(satir_no);
            text_olcu.Text = "";
            calc_brut.Value = 0;
            calc_adet.Value = 1;
            calc_kapak.Value = 0;
            calc_palet.Value = 0;
            calc_net.Value = 0;
            text_olcu.Focus();
        }
        private void FormuDZYN()
        {

            StiReport report = new StiReport();

            report.Load("" + AppPath + "\\Form\\SEVKBRK.MRT");
            report.Dictionary.Databases.Clear();
            report.Dictionary.Databases.Add(new StiSqlDatabase("RAPORDATA", "" + sqlconnectstr + ""));
            report["@sipRECno"] = siparis_RECno;
            report["@sevksatirno"] = secilen_satirno;

            report.Design();
            report.Save("" + AppPath + "\\Form\\SEVKBRK.MRT");



        }
        private void FormuEKRANA()
        {

            StiReport report = new StiReport();

            report.Load("" + AppPath + "\\Form\\SEVKBRK.MRT");
            report.Dictionary.Databases.Clear();
            report.Dictionary.Databases.Add(new StiSqlDatabase("RAPORDATA", "" + sqlconnectstr + ""));
            report["@sipRECno"] = siparis_RECno;
            report["@sevksatirno"] = secilen_satirno;



            report.ShowWithWpf();



        }
        private void FormuYAZDIR()
        {

            StiReport report = new StiReport();

            report.Load("" + AppPath + "\\Form\\SEVKBRK.MRT");
            report.Dictionary.Databases.Clear();
            report.Dictionary.Databases.Add(new StiSqlDatabase("RAPORDATA", "" + sqlconnectstr + ""));
            report["@sipRECno"] = siparis_RECno;
            report["@sevksatirno"] = secilen_satirno;



            report.Print();



        }

        private void net_hesapla()
        {
            calc_net.Value = calc_brut.Value - (calc_kapak.Value + calc_palet.Value);
        }
        private void labelControl4_Click(object sender, EventArgs e)
        {

        }

        private void calc_brut_EditValueChanged(object sender, EventArgs e)
        {
            net_hesapla();
        }

        private void calc_palet_EditValueChanged(object sender, EventArgs e)
        {
            net_hesapla();
        }

        private void calc_kapak_EditValueChanged(object sender, EventArgs e)
        {
            net_hesapla();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (calc_net.Value > 0)
            {
                ceki_liste_kaydet();
                _1_dgv_guncelle();
                degiskenSifirla();
                
            }
            else { MessageBox.Show("Miktar Girişi Yapılmalı "); }
        }

        private void combo_nakiyeci_SelectedIndexChanged(object sender, EventArgs e)
        {
            //combo_telefon.Text = "";
            //combo_plaka.Text = "";
            //if (combo_nakiyeci.SelectedIndex > 0)
            //{
            //    combo_plaka.DataSource = sqlbaglanti.ShowTable("select sof_plaka AS KOD,sof_plaka AS ADI FROM TK_CEK_SOFOR_TANIMLARI WHERE sof_kodu='"+combo_nakiyeci.SelectedValue.ToString()+"' ORDER BY sof_adi ", CommandType.Text);
            //    combo_plaka.DisplayMember = "ADI";
            //    combo_plaka.ValueMember = "KOD";

            //    combo_telefon.DataSource = sqlbaglanti.ShowTable("select sof_cep_tel AS KOD ,sof_cep_tel AS ADI FROM TK_CEK_SOFOR_TANIMLARI  WHERE sof_kodu='" + combo_nakiyeci.SelectedValue.ToString() + "' ORDER BY sof_adi ", CommandType.Text);
            //    combo_telefon.DisplayMember = "ADI";
            //    combo_telefon.ValueMember = "KOD";
            //}
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                int index1 = gridView1.FocusedRowHandle;
                Int32 secim_RECno = Convert.ToInt32(gridView1.GetRowCellValue(index1, "KAYITNO").ToString());
                text_olcu.Text = Convert.ToString(gridView1.GetRowCellValue(index1, "ÖLÇÜ").ToString());
                calc_brut.Value = Convert.ToInt32(gridView1.GetRowCellValue(index1, "BRÜT").ToString());
                calc_palet.Value = Convert.ToInt32(gridView1.GetRowCellValue(index1, "PALET").ToString());
                calc_kapak.Value = Convert.ToInt32(gridView1.GetRowCellValue(index1, "KAPAK").ToString());
                calc_adet.Value = Convert.ToInt32(gridView1.GetRowCellValue(index1, "ADET").ToString());
                calc_net.Value = Convert.ToInt32(gridView1.GetRowCellValue(index1, "NET").ToString());
                text_olcu.Focus();
            }
            catch { }
        }

      

        private void combo_telefon_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            { text_olcu.Focus(); }
        }

        private void calc_adet_EditValueChanged(object sender, EventArgs e)
        {
            if (calc_adet.Value == 0)
            { MessageBox.Show("MİKTAR 0 OLAMAZ"); calc_adet.Value = 1; }
        }

        private void satırSilToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int index1 = gridView1.FocusedRowHandle;
                Int32 secim_RECno = Convert.ToInt32(gridView1.GetRowCellValue(index1, "KAYITNO").ToString());
                if (MessageBox.Show("" + secim_RECno + "  Nolu kayıt Silinecek Onaylıyormusunuz.  ", "Onay Ekranı", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    sqlbaglanti.CommScalar("UPDATE TK_CEKI_LISTESI SET cek_kapat=0,cek_evrakno_seri='',cek_evrakno_sira=0 ,cek_sip_nakliyeci=''"
                        +",cek_sip_nakliyeci_tel='' ,cek_sip_nakliyeci_plaka=''  WHERE cek_RECno="+secim_RECno+"",CommandType.Text);
                    _1_dgv_guncelle();
                }


            }
            catch { MessageBox.Show("SECİM YAPILAMADI"); }
        }

        private void barkodTasarımToolStripMenuItem_Click(object sender, EventArgs e)
        {
           
        }

        private void barkodBasımToolStripMenuItem_Click(object sender, EventArgs e)
        {

            int index1 = gridView1.FocusedRowHandle;
            secilen_satirno= Convert.ToInt32(gridView1.GetRowCellValue(index1, "SNO").ToString());

            FormuEKRANA();
        }

        private void listeYazdırToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());
            link.Component = gridControl1; //yazdıracağımız grid’i gösteriyoruz.
            link.Landscape = true; //kenarlıkların, boşlukların görüntülenmesini sağlıyoruz.
            link.PageHeaderFooter = true;
            link.RtfReportHeader = "Çeki Listesi";
            link.ShowPreview(); //yazdırılacak gridi ekranda gösteriyoruz
        }

        private void yenileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _1_dgv_guncelle();
        }

        private void çekiListesiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StiReport report = new StiReport();

            report.Load("" + AppPath + "\\Form\\CEKILISTESI.MRT");
            report.Dictionary.Databases.Clear();
            report.Dictionary.Databases.Add(new StiSqlDatabase("RAPORDATA", "" + sqlconnectstr + ""));
            report["@musterikodu"] = musteri_kodu;
            report["@sevkevraknoseri"] = cek_evrakno_seri;
            report["@sevkevraknosira"] = cek_evrakno_sira;




            report.ShowWithWpf();
        }

        private void barkodTasarımToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            int index1 = gridView1.FocusedRowHandle;
            secilen_satirno = Convert.ToInt32(gridView1.GetRowCellValue(index1, "SNO").ToString());

            FormuDZYN();
        }

        private void çekiListesiTasarımToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StiReport report = new StiReport();

            report.Load("" + AppPath + "\\Form\\CEKILISTESI.MRT");
            report.Dictionary.Databases.Clear();
            report.Dictionary.Databases.Add(new StiSqlDatabase("RAPORDATA", "" + sqlconnectstr + ""));
            report["@musterikodu"] = musteri_kodu;
            report["@sevkevraknoseri"] = cek_evrakno_seri;
            report["@sevkevraknosira"] = cek_evrakno_sira;




            report.Design();
           
            report.Save("" + AppPath + "\\Form\\CEKILISTESI.MRT");

        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {

            //combo_nakiyeci.DataSource = sqlbaglanti.ShowTable("select sof_kodu AS KOD,sof_adi AS ADI FROM TK_CEK_SOFOR_TANIMLARI  ORDER BY sof_adi ", CommandType.Text);
            //combo_nakiyeci.DisplayMember = "ADI";
            //combo_nakiyeci.ValueMember = "KOD";

        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            SISTEM.NakFirmaTanitim fr = new SISTEM.NakFirmaTanitim();
            fr.aktif_kullanici = aktif_kullanici;
            fr.ShowDialog();
            //combo_firma.DataSource = sqlbaglanti.ShowTable("select nak_kodu AS KOD,nak_unvani AS ADI FROM TK_NAKLIYE_FIRMA_TANIMLARI ORDER BY nak_unvani ", CommandType.Text);
            //combo_firma.DisplayMember = "ADI";
            //combo_firma.ValueMember = "KOD";

                 
        }
        private void BarkodOku()
        {

            int isleme_devam = 1;

            int varmi = Convert.ToInt16(sqlbaglanti.CommScalar("SELECT  count(*) FROM TK_CEKI_LISTESI WHERE cek_barkodu=" + barkod + "", CommandType.Text));
            if (varmi>0) { isleme_devam = 0; } else { isleme_devam = 1; MessageBox.Show("BARKOD BULUNAMADI"); }


            if (isleme_devam == 0)
            {
                string kimin = Convert.ToString(sqlbaglanti.CommScalar("SELECT cek_musteri_kodu FROM TK_CEKI_LISTESI WHERE cek_barkodu=" + barkod + "", CommandType.Text));
                if (musteri_kodu == kimin) { isleme_devam = 0; } else { isleme_devam = 1; MessageBox.Show("BU MÜŞTERİNİN ÜRÜNÜ DEĞİL"); }
            }

            if (isleme_devam == 0)
            {
                string durum = Convert.ToString(sqlbaglanti.CommScalar("SELECT cek_kapat FROM TK_CEKI_LISTESI WHERE cek_barkodu=" + barkod + "", CommandType.Text));
                if (durum == "0") { isleme_devam = 0; } else { isleme_devam = 1; MessageBox.Show("DAHA ÖNCE SEVKİYAPILMIŞ TEKRAR OKUTULAMAZ"); }
             
            }
            if (isleme_devam == 0)
            {   
                  
                
                sqlbaglanti.CommScalar("UPDATE TK_CEKI_LISTESI SET   cek_satirno="+satir_no+" , cek_evrakno_seri='" + cek_evrakno_seri + "',cek_evrakno_sira=" + cek_evrakno_sira + " ,  cek_kapat=1,[cek_sip_nakliyeci]='" + text_sofor.Text + "' ,[cek_sip_nakliyeci_tel]='" + text_telefon.Text + "'       ,[cek_sip_nakliyeci_plaka]='" + text_plaka.Text + "'   "
                +"  WHERE cek_barkodu=" + barkod + "", CommandType.Text);
                   _1_dgv_guncelle();
             }            
            
        }
        
        private void buttonEdit1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
               
              BarkodOku();
            }
        }

        private void AcikBarkodlariGetir()
        {
            CekListesi.KayıtSecimEkrani fr = new KayıtSecimEkrani();
            fr.sqlsorgu = "select * from dbo.tkfn_AcikBarkodlariGosterMusterili('" + musteri_kodu + "')";
            fr.secim_tipi = "barkod";
            fr.ShowDialog();
           
           
        }
        private void text_barkod_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            AcikBarkodlariGetir();
        }

        private void simpleButton4_Click(object sender, EventArgs e)
        {
            StiReport report = new StiReport();

            report.Load("" + AppPath + "\\Form\\CEKILISTESI.MRT");
            report.Dictionary.Databases.Clear();
            report.Dictionary.Databases.Add(new StiSqlDatabase("RAPORDATA", "" + sqlconnectstr + ""));
            report["@musterikodu"] = musteri_kodu;
            report["@sevkevraknoseri"] = cek_evrakno_seri;
            report["@sevkevraknosira"] = cek_evrakno_sira;




            report.ShowWithWpf();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            
           
        }

        private void simpleButton5_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(" Siparis Kapatmayı Onaylıyormusunuz.  ", "Onay Ekranı", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
            {
                sqlbaglanti.CommScalar("UPDATE TK_CEKI_LISTESI SET cek_kapat=2  WHERE cek_evrakno_seri='" + cek_evrakno_seri + "' and cek_evrakno_sira=" + cek_evrakno_sira + "", CommandType.Text);
                _1_dgv_guncelle();

                StiReport report = new StiReport();

                report.Load("" + AppPath + "\\Form\\CEKILISTESI.MRT");
                report.Dictionary.Databases.Clear();
                report.Dictionary.Databases.Add(new StiSqlDatabase("RAPORDATA", "" + sqlconnectstr + ""));
                report["@musterikodu"] = musteri_kodu;
                report["@sevkevraknoseri"] = cek_evrakno_seri;
                report["@sevkevraknosira"] = cek_evrakno_sira;
                report.ShowWithWpf();
                _1_satırSilToolStripMenuItem.Enabled = false;


            }
        }

        private void buttonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            text_irs_sira.Text=Convert.ToString( sqlbaglanti.CommScalar("Select isnull(MAX(sth_evrakno_sira),0)+1 FROM STOK_HAREKETLERI WITH (NOLOCK, INDEX=NDX_STOK_HAREKETLERI_05) WHERE sth_tip=1 and  sth_cins=0 and   sth_evrakno_seri=N'" +text_irs_seri.Text + "' and sth_evraktip=1", CommandType.Text));
        
        }

        private void simpleButton5_Click_1(object sender, EventArgs e)
        {
            kayitIslemineBasla();
        }

      

    }
}